use strict;


=head1 NAME

  RTx::AssetTracker::CurrentUser -- Class Description
 
=head1 SYNOPSIS

  use RTx::AssetTracker::CurrentUser

=head1 DESCRIPTION


=head1 METHODS

=cut

package RTx::AssetTracker::CurrentUser;

use vars qw( @ISA );
@ISA= qw(RT::CurrentUser);

# {{{ sub _Init

#The basic idea here is that $self->CurrentUser is always supposed
# to be a CurrentUser object. but that's hard to do when we're trying to load
# the CurrentUser object

sub _Init {
    my $self = shift;
    my $User = shift;

    $self->{'table'} = "Users";

    if ( defined($User) ) {

        if (   UNIVERSAL::isa( $User, 'RT::User' )
            || UNIVERSAL::isa( $User, 'RTx::AssetTracker::User' )
            || UNIVERSAL::isa( $User, 'RTx::AssetTracker::CurrentUser' )
            || UNIVERSAL::isa( $User, 'RT::CurrentUser' ) )
        {
            $self->Load( $User->id );

        }
        elsif ( ref($User) ) {
            $RT::Logger->crit(
                "RTx::AssetTracker::CurrentUser->new() called with a bogus argument: $User");
        }
        else {
            $self->Load($User);
        }
    }

    $self->_BuildTableAttributes();

}
# }}}

# {{{ sub UserObj

=head2 UserObj

  Returns the RT::User object associated with this CurrentUser object.

=cut

sub UserObj {
    my $self = shift;

        use RTx::AssetTracker::User;
        my $user = RTx::AssetTracker::User->new($self);

        unless ($user->Load($self->Id)) {
            $RT::Logger->err($self->loc("Couldn't load [_1] from the users database.\n", $self->Id));
        }
    return ($user);
}
# }}}

1;
